home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Offline-Mailing < prev    next >
Text File  |  1997-02-08  |  40KB  |  996 lines

  1.   Linux off-line mailing method (offline mailaddr with 1account)
  2.   Gunther Voet, freaker@tuc.ml.org - Belgium (CompuMed/TuCSRV)
  3.   v1.3.2, 7 February 1998
  4.  
  5.   Use your linux mailing system offline, receive mail for multiple users
  6.   with only one email address, and without being 24-24 online on the
  7.   net.  If you are unable to pay a direct line to stay online for 24-24
  8.   and still want your users to receive mail on your linux box; as well
  9.   not pay for a multi-drop box at your isp, you can use this system
  10.   using only one email address to divide to your users email addresses.
  11.   It is as well 24-24 reachable since the server where your account
  12.   resists will receive the mail.  ``This howto is Copyright (c)1997-98
  13.   by Gunther Voet.''
  14.  
  15.   1.  Notes by the author (preface).
  16.  
  17.   In this chapter i'm just going to put myself safe for any damages and
  18.   flames - since even *I* could be wrong ... If you got any questions or
  19.   suggestions to add to this faq, even if you find any faults - there is
  20.   a feedback section in it ...
  21.  
  22.   Some "need to know" point is, all filenames & files/types are
  23.   indicated with the line:
  24.  
  25.        (*** < file > *** text ***)     .procmailrc
  26.  
  27.   This means, this is a file, called ".procmailrc" containing text. The
  28.   text variable can also be code. It shows you what name of file to use.
  29.   Without a path means it can be variable/choosen by you (in the most
  30.   cases this files resists in the homedirectory of the mail"user" like
  31.   /home/mailer).
  32.  
  33.   1.1.  Legal stuff
  34.  
  35.   Neither the author nor the distributors of this HOWTO are in any way
  36.   responsible for physical, financial, moral damage incurred by
  37.   following the suggestions and examples of this text. The information
  38.   in this document contains the best of my knowledge and experience, but
  39.   i could still make any mistakes as well in the information as in the
  40.   examples. Any trademarks are property of their respective holders (i
  41.   ain't using any commercial thingy's here - but well - IF i'm going to
  42.   add some text, i don't need to change this disclaimer). If your cat
  43.   dies 'coz this document was too heavy - i am not responsible as well
  44.   ...
  45.  
  46.   1.2.  Copyrights
  47.  
  48.   This document and contents are Copyright (c)1997-98 by Gunther Voet.
  49.   Unauthorized (re)production in any form is explicitly allowed and even
  50.   strongly encouraged as long you don't change the contents of it
  51.   without contacting the author (Gunther Voet). If you quote the
  52.   document as whole or a part of it, there needs to be a Copyright
  53.   "hint" or link to the derived work. "The HOWTO documents are
  54.   copyrighted by their respective authors". The "HOWTO copyright" will
  55.   discuss what can be done and what cannot be done with this document.
  56.   If it is used in a commercial way, the author should been noticed for
  57.   such distributions. Exceptions on this copyright may be granted under
  58.   certain conditions with a written letter or e-mail to the author. For
  59.   more info about the standard HOWTO disclaimer, please contact
  60.   gregh@sunsite.unc.edu.
  61.  
  62.   *PLEASE* *IF* you are going to make a system based on this HOWTO, then
  63.   PLEASE give me the copyright :) heh ... - i am not that cruel :)). I
  64.   mean by a system "a package" - NOT the mailsystem itself - altough it
  65.   is some appreciative thingy i would be included :)) i can always use
  66.   one email address more for more flaming :)) (just kiddin').
  67.  
  68.   1.3.  Feedback
  69.  
  70.   Well, i expect from you and the users who read this HOWTO, they will
  71.   make this HOWTO useful. If you got any suggestions, corrections,
  72.   comments (except flame-mail :)) - please send them to me at
  73.   freaker@tuc.ml.org and i will make the corrections, comments or
  74.   suggestions happen in the next revision. If you publish this document
  75.   on a commercial way, a complimentary copy would be appreciated - you
  76.   can mail me for my postal address. For flames - you could send them to
  77.   me, but they will end at /dev/null ... so - don't even mind to waste
  78.   bandwidth for it !.  Since i can exclude some users to receive mail
  79.   from (explained in this document) (evil grin). My alias (name) is
  80.   freaker btw :)). You can always try "freaker@ibm.net".
  81.  
  82.   1.4.  Distribution
  83.  
  84.   The latest revision of this document can been get from:
  85.  
  86.   http://sunsite.unc.edu/pub/Linux/docs/HOWTO/mini/Offline-Mailing
  87.  
  88.   -and-
  89.  
  90.   http://tuc.ml.org/om/
  91.  
  92.   (also checkout http://tuc.ml.org)
  93.  
  94.   1.5.  Changes
  95.  
  96.    v1.0.0       - Preliminary release, internal testing, we tried it before
  97.                   we gave it out to you :) .. since - it GOT to be usefull
  98.                   and needs to work? rite ? :)
  99.    v1.1.0       - Fixed a lot of errors in the texts, put chapters in it,
  100.                 - fixed some small errors and typo's ...
  101.    v1.2.0       - fixed grammatical errors.
  102.                 - added a "what-are-we-using" chapter.
  103.                 - added Sunsite address.
  104.    v1.3.0       - Added "virtual mail support" for admins
  105.                 - New site and email addresses
  106.                 - Thanks go to ...
  107.    v1.3.1       - Converted to SGML and fixed some minor details.
  108.    v1.3.2       - Major errors corrected (filenames .fetchmailrc to
  109.                   .procmailrc) etc... (thx to Tetsu Isaji)
  110.                 - Added support for the "new" sendmail, v8.8.0+
  111.                 - Fixed some minor errors
  112.                 - Upgraded my system YAY!
  113.                 - Japanese version will come out soon, location
  114.                   will be mentioned when known ... (thx to Tetsu Isaji)
  115.  
  116.   1.6.  What am i using ?
  117.  
  118.   I'm using Linux 2.0.30, Pentium-166, ATI pci-mach64 card, Accelerated-
  119.   X (Metro) and a connection to my isp (currently ibmnet) via ppp using
  120.   a ZyXEL 28k8 modem, and occasionally a Bausch 28k8.
  121.  
  122.   Now i upgraded to Linux 2.0.33, installed a USRobotics modem, it still
  123.   works as it should work :) (everybody should upgrade their linux
  124.   versions as soon there comes out a patch :) believe me :) you could
  125.   spare a lot of time & seeking for errors when doing this one :)
  126.  
  127.   1.7.  Thanks go out to ...
  128.  
  129.   ╖  Fred, durban.hebel.net (for allowing the pages & bot)
  130.  
  131.   ╖  Lifesaver, parkside.net (for allowing the new pages, helping with
  132.      this faq for mailing, since, it is all working overthere and here
  133.      ... make some visit to his cyber-cafe ... heard they got great
  134.      coffee :))
  135.  
  136.   ╖  The server admins at lodus.net to continue this project.
  137.  
  138.   2.  Preliminaries
  139.  
  140.   Well, how does this system works ? what can you do with it ? what is
  141.   it anyway ? and ... am i used to read it ? ... to all those questions
  142.   - there is an answer ...
  143.  
  144.   2.1.  Preface & Description
  145.  
  146.   This HOWTO is dedicated to all the off-line linux users/servers ...
  147.   You got a group, or organization, and you want all your members to
  148.   have a contact (email) address, without paying for the 24/24 direct
  149.   line or for the email accounts ... Or you got a internal network -
  150.   with a masq'd server and you want to give all the users using it a
  151.   email address, you could use this way to do it. I personally am using
  152.   it to give my users & members of a demogroup all a e-mail account
  153.   without being 24/24 online; since it is a non-commercial demogroup -
  154.   and we don't got THAT much money to pay a direct line with instant
  155.   email access - and different ip's. Everybody got a email address, even
  156.   when they don't got internet access. The ones with internet access can
  157.   receive their mail on their personal email address - viavia the system
  158.   described below. Your users can still send mail as they used to do,
  159.   since - your system will hold the mail queue from the users. The only
  160.   thing what should be changed for the users - is that they add their
  161.   "email address" wether (described below) it is the method with the
  162.   subject line, or with the header "to" ...
  163.  
  164.   2.2.  Points of interest ...
  165.  
  166.   ╖  A organization with members, for all a email address, so they can
  167.      be contacted when neccesary.
  168.  
  169.   ╖  A anonymous mailservice - they can't read your "mail setup file" -
  170.      so they don't know where the mail is forwarded/rerouted to.
  171.  
  172.   ╖  A group who doesn't got enuf money (don't laugh), or is free, and
  173.      don't WANT to spend money for it (eheh) - and still wants to
  174.      provide the members a email address.
  175.  
  176.   ╖  A masq'd network - with a server connected to the internet, where
  177.      the users using the masq'd network need to have a email account
  178.  
  179.   ╖  You want to put some documents "autoreplied" - like i do with my
  180.      HOWTO, statistics, or documents ... like "info@yourmail.dom" or
  181.      "document1@yourmail.dom".
  182.  
  183.   ╖  You only need one account at the "main" server to fetch from, for
  184.      the +200 email accounts you can create at your server ...
  185.  
  186.   ╖  I used the "B" method with +- 300 email accounts - with a public
  187.      server; 80486DX4-100 - and was processed in 1 minute.
  188.  
  189.   2.3.  Things you should know
  190.  
  191.   ╖  Not every (free) mailservice is happy when you are going to
  192.      distribute mail to other users, or putting up an anonymous mail
  193.      server, so, please try to contact your mailserver administrator
  194.      before "just doing it".
  195.  
  196.   ╖  It is slower than a direct 24/24 connection, since your server will
  197.      need to get online before it will process the mail.
  198.  
  199.   ╖  It needs a administrative force to administrate the "mailrouting"
  200.      and to add the user ... you will need work with it ! - it is not
  201.      that automatic.  (well - i made it "semi-automatic" with my server
  202.      :) you could try it as well).
  203.  
  204.   ╖  Bandwidth and space is needed when you got many users - on the
  205.      mailserver you are working on ... and sure - when they send files -
  206.      you need to have enough space on it !.
  207.  
  208.   ╖  All mail will be transferred into "one step" - so - the last mail
  209.      received on your server will be last sent to the recipient. "first
  210.      in - first out".
  211.  
  212.   ╖  In the first method (to:) there is no prob with the usernames - but
  213.      in the second "cheaper" method - users can't put in a subject line,
  214.      since that one will be used to send the mail to the recipient. Many
  215.      users forget to use the "subject" ... - or they will need to know
  216.      it clearly.
  217.  
  218.   ╖  If you poll enough for your mail, (for example 4 times a day) - the
  219.      mail will be sure be delivered to as from a recipient the least
  220.      every 6hrs. So the processing will go a little smoother.
  221.  
  222.   ╖  you CAN use it as a "online" mail server as well :) since it will
  223.      poll for it's mail for every XX minutes. but - when you are online
  224.      - why using another server ? and not asking your own domain for
  225.      your own server ?  (dough).
  226.  
  227.   2.4.  there are 2 different ways ...
  228.  
  229.   1. method 'A' - now called "(m(A))".
  230.  
  231.      The "mailsystem" will look to the header, and will see to the "to:"
  232.      line.  This is the best way, since it are "real email addresses".
  233.      You will need another account on some server *AND* you need a DNS
  234.      (MX) entry (your own domain for instance). If the system
  235.      administrator wants to help you with that, then there will be no
  236.      problem !. The system administrator will need to reroute ALL mail
  237.      sent to your (MX) maildomain -> to your account !.  This will take
  238.      some time for him to do it :) so be really nice to him :)) Thanks
  239.      to my system administrator (Fred) i got my maildomain and the user-
  240.      services of my "free" demogroup. It can be a DNS entry costs
  241.      something, what you will need to consider to take it or not.
  242.  
  243.   2. method 'B' - now called "(m(B))".
  244.  
  245.      The "mailsystem" looks to the subject line, and will forward to the
  246.      user indicated into the subject line. If the user is not found, it
  247.      will bounce a mail back. This will need a pop server with only one
  248.      useraccount, and don't need your own DNS or you don't need to be
  249.      nice to your system- administrator who arranges you the mail
  250.      address :). You can use a public mailserver, as well your own
  251.      mailserver or a private one. You can even sacrifice your own email
  252.      address for it :). I used this approach as first what worked for me
  253.      for over a year now ... I know this is sloppy, but, i ain't telling
  254.      you need to use this way, so don't shoot ME - since i'm only
  255.      offering you some solutions to your mail problems :) - you could
  256.      use method A what isn't that sloppy !
  257.  
  258.   3.  Requirements
  259.  
  260.   Well, you need (of'course) a Linux machine, what can be connected to
  261.   the internet - So! (i am smart - i am smart :)) - you probably got a
  262.   modem, right?  a phoneline - or any way to connect yourself with the
  263.   server you are running.  You will also need some software like
  264.   Fetchmail, Procmail, an extra account, and your email account or DNS
  265.   with email account.
  266.  
  267.   3.1.  A linux machine
  268.  
  269.   This can be ANYthing ... even a 8086 ... - but preferable - since
  270.   there will be some load on it - minimally a 80386 :). as faster the
  271.   machine - as faster the software will run (rite eh)? :).
  272.  
  273.   3.2.  A extra account at your linux machine
  274.  
  275.   You need to create a extra account on your Linux machine. I am using
  276.   as example (in this HOWTO) "mailservice". This can be as well
  277.   "mailserver" or "mailtousers" - as long it is some name what can be
  278.   recognized by you!.
  279.  
  280.   ! It doesn't need to have ANY root privileges !
  281.  
  282.   This mailaccount will forward all mail to the users on your system, or
  283.   to external users (not on your system :)). Just create it as an
  284.   ordinary user.  You will need to test things under this account, and,
  285.   the mail "administrator" can use this account to administrate the mail
  286.   account without being root even .. so - pretty safe !.
  287.  
  288.   3.3.  Fetchmail
  289.  
  290.   I am using v1.9 patch level 9 ... i found it at sunsite.unc.edu, and,
  291.   i am using only this mail-fetcher in my example - if you want to use
  292.   another one, you are on your own ! since i am happy with it :). For
  293.   extended features you should read the man of Fetchmail :). This can be
  294.   installed as root - as well for the user itself ... - best is to
  295.   install it as root :) since i know it will work for sure then :)))
  296.   3.4.  Procmail
  297.  
  298.   I am using v3.10 - found it again at sunsite.unc.edu, and - i like
  299.   this as the best mda (mail delivery agent) around ... It delivers
  300.   nicely - and it is better than using it by the "original" system mda -
  301.   since it will deliver user-per-user ! ... The same as above - it can
  302.   be installed as root, or as user - and :) best is to install it as
  303.   root - since i know it will work for sure then (again!) :)... how
  304.   repetetive ...
  305.  
  306.   3.5.  A mail account
  307.  
  308.   You always need to have a mail account - where you can "poll" your
  309.   mail from.  The server needs to be a POP server - where you can poll
  310.   from when you want, and where users can send their mail 24/24 to. It
  311.   can be a free-mail service, as well commercial - even your mailaccount
  312.   is sufficient enough. In the "subject" method (m(B)) - you don't need
  313.   something more - in method A - with the "to" fields - you NEED more -
  314.   as written below !
  315.  
  316.   3.5.1.  A DNS record (MX)
  317.  
  318.   Needed to run your own "domain" - email domain ... it is needed since
  319.   the administrator of the server can't use it's own domain for your
  320.   users - since there are users who need to be contacted on his server
  321.   as well - what could interfere with your users. And your mailheader
  322.   must be filtered on that domain. So - an apart domain - pointing to
  323.   HIS server. This can be an additional cost - or you can ask your
  324.   system administrator to add a "non- authorative address" - pointing to
  325.   his server ... - however - it needs to be another domain than he is
  326.   using !
  327.  
  328.   3.5.2.  A "forward" to your account-account :)
  329.  
  330.   Well, the system administrator needs to forward *ALL* mail to your
  331.   domain to YOUR account ... - it is easy for him when he knows how to
  332.   do it :) ..  else he will need to read the sendmail manual :)) (or
  333.   qmail - whatever).  You will poll for your mail at your account and
  334.   voila ! filtering on YOUR own email domain.
  335.  
  336.   4.  I got it all, what now ?
  337.  
  338.   Now you created the extra account, you got the mail address - and/or
  339.   the DNS entry & forwarding to your account ... As well installed
  340.   Procmail & Fetchmail so we can rock the place ! :) .. here we go !
  341.  
  342.   1. You need to create a .procmailrc file, what will contain the
  343.      "delivery" info to your users.
  344.  
  345.   2. You need to create a "nosuchuserfile" - so the writer knows his
  346.      mail isn't delivered well.
  347.  
  348.   3. For best work :) you could use crontab to check for mail. This is a
  349.      easy way to check your mail every XX minutes when on the internet.
  350.  
  351.   4.1.  Creating a .fetchmailrc file
  352.  
  353.   You will need to create a .fetchmailrc file, what will contain the
  354.   information (username & password, as well the Mail Delivery Agent
  355.   (mda) to proces the mail to). Here is some example file ...
  356.  
  357.        (*** < file > *** text ***)     .fetchmailrc
  358.  
  359.        ______________________________________________________________________
  360.        server my.mail.server.com
  361.        proto pop3
  362.        user myaccountthere
  363.        pass deepestsecrets
  364.        flush
  365.        mda /usr/bin/procmail
  366.        ______________________________________________________________________
  367.  
  368.   This file will be used to fetch your mail. Please test it by using the
  369.   fetchmail program "fetchmail -vv" - and see your mail is being
  370.   transferred right ... There will be some errors - since the procmail
  371.   control file hasn't been created yet. You can wait by testing AFTER
  372.   making the procmailrc file, but - i'll warn ya - IF there is something
  373.   fault :) it CAN be this file :) It needs to be owned by the user
  374.   account itself - in my case "mailservice" and needs to be "user
  375.   readable" but NOT group/world readable - since it contains the "main
  376.   password" :)). (chmod 600 .fetchmailrc will do).
  377.  
  378.   4.2.  Creating a .procmailrc file
  379.  
  380.   This control file will forward all mail to the users in it. There are
  381.   2 ways as described before - the "to:" (header) way - and the
  382.   "subject" (sloppy) way.  The file will contain the usernames to
  383.   transport to. All the "#" are comments and are absolutely not needed
  384.   when not wanted - it's only so you know what i am doing ... - you can
  385.   as well best chmod it 600 - so the rest of the world or group doesn't
  386.   need those private addresses eh :) ... It needs also to be owned by
  387.   the user (like "mailservice") :)). The "nosuchuserfile" is a "bounce"
  388.   to the writer - if the user isn't found (so mail not delivered) in the
  389.   procmailrc file ... - so the writer knows the mail isn't delivered
  390.   well.
  391.  
  392.   4.2.1.  For "header (to:)" transportation
  393.  
  394.        (*** < file > *** text ***)     .procmailrc
  395.  
  396.   ______________________________________________________________________
  397.   # this line is for debugging purposes only ! it should be removed for
  398.   # ethical purposes - since you can read all mail passed trough your mail-
  399.   # server ... - all mail will be copied to the file "passtrough" before
  400.   # going to the users ... herein you can look what went wrong ...
  401.   :0 c
  402.           passtrough
  403.  
  404.   # the mail with header "to: freaker@mydom.com" will be forwarded directly
  405.   # to me, the other mail will pass this option ...
  406.   :0
  407.   * ^To:.*freaker@mydom.com
  408.   ! freaker
  409.  
  410.   # the mail to root@mydom.com will be forwarded to root ... as well postmaster!
  411.   :0
  412.   * ^To:.*root@mydom.com
  413.   ! root
  414.  
  415.   :0
  416.   * ^To:.*postmaster@mydom.com
  417.   ! postmaster
  418.  
  419.   # the mail to barbara@mydom.com will be forwarded to barbara AND will be
  420.   # forwarded to her private email address !
  421.  
  422.   :0 c
  423.   * ^To:.*barbara@mydom.com
  424.   ! barbara@her.private.one
  425.  
  426.   :0
  427.   * ^To:.*barbara@mydom.com
  428.   ! barbara
  429.  
  430.   # this lines will BOUNCE the mail to the sender - when it is not delivered to
  431.   # one of above users ... it will send the file "nosuchuser" into the mail
  432.   # body as reply ... be aware ! you need to make such file ! - mine contains
  433.   # "well, the user you wanted to reach does not exist on this server, please
  434.   # try again, it could be the user is not present anymore".
  435.   #
  436.   :0
  437.     |(/usr/bin/formail -r -k \
  438.        -A"X-loop: mailservice@mydomain.dom "| \
  439.          /usr/bin/gawk '{print }\
  440.          /^/ && !HEADER \
  441.            { system("/bin/cat nosuchuser"); \
  442.            print"--" ;\
  443.            HEADER=1 }' ) |\
  444.            /usr/bin/sendmail -t
  445.  
  446.   exit
  447.   ______________________________________________________________________
  448.  
  449.   4.2.2.  For "subject: touser" transportation
  450.  
  451.        (*** < file > *** text ***)     .procmailrc
  452.  
  453.        ______________________________________________________________________
  454.        # this line is for debugging purposes only ! it should be removed for
  455.        # ethical purposes - since you can read all mail passed trough your mail-
  456.        # server ... - all mail will be copied to the file "passtrough" before
  457.        # going to the users ... herein you can look what went wrong ...
  458.        :0 c
  459.                passtrough
  460.  
  461.        # the mail with header "to: freaker@ibm.net" will be forwarded directly
  462.        # to me, the other mail will pass this option ... When you got a "dedicated"
  463.        # email address to receive your "mailservice thingy's" on - you don't need
  464.        # to use this line :)
  465.        :0
  466.        * ^To:.*freaker@ibm.net
  467.        ! freaker
  468.  
  469.        # all mail with as subject "root" will be forwarded to root !
  470.        :0
  471.        * ^Subject:.root
  472.        ! root
  473.  
  474.        # all mail to "subject: barbara" will be forwarded to barbara ...
  475.        :0
  476.        * ^Subject:.barbara
  477.        ! barbara
  478.  
  479.        # all mail to "subject: paul" will be forwarded to his external email addr.
  480.        :0
  481.        * ^Subject:.paul
  482.        ! paul@his.personal.emailaddress
  483.  
  484.        # all mail to "subject: john" will be forwarded to his account at your server
  485.        # and a copy will go to his private email address ...
  486.        :0 c
  487.        * ^Subject:.john
  488.        ! john@his.personal.emailaddress
  489.  
  490.        :0
  491.        * ^Subject:.john
  492.        ! john
  493.  
  494.        # All the mail from ibm, with their updates and information, will go to
  495.        # freaker, as he is the one who will administrate the mailservice, and
  496.        # as ibm doesn't want to get the bounce putten below !! ... this is
  497.        # neccesary if your mail provider sends "newsletters" etc...
  498.        :0
  499.        * ^From:.*newsletter@ibm.net
  500.        ! freaker
  501.  
  502.        # All messages from the daemon should been thrown away, or in my case, will
  503.        # be saved to a file ... (use /dev/null to throw to endless pits of The Abyss)
  504.        :0
  505.        * ^FROM_DAEMON
  506.        throwaway
  507.  
  508.        # this lines will BOUNCE the mail to the sender - when it is not delivered to
  509.        # one of above users ... it will send the file "nosuchuser" into the mail
  510.        # body as reply ... be aware ! you need to make such file ! - mine contains
  511.        # some text like "user not found in subject line, please use "Subject: user"
  512.        # to write a mail to the user, like example "subject: freaker" would send a
  513.        # mail to freaker." The file can be long, but also small :) ... the
  514.        # "mailservice@mydomain.dom" will prevent to loop between your server and
  515.        # the other server - it needs to have the EXACT email address used !.
  516.        # Else you could create an endless loop with a server what sends mail
  517.        # to "your email address" with as subject something like "don't spend 500$
  518.        # at your ..." etc...
  519.   :0
  520.     |(/usr/bin/formail -r -k \
  521.        -A"X-loop: mailservice@mydomain.dom "| \
  522.          /usr/bin/gawk '{print }\
  523.          /^/ && !HEADER \
  524.            { system("/bin/cat nosuchuser"); \
  525.            print"--" ;\
  526.            HEADER=1 }' ) |\
  527.            /usr/bin/sendmail -t
  528.  
  529.   exit
  530.   ______________________________________________________________________
  531.  
  532.   4.3.  nosuchuserfile"
  533.  
  534.        (*** < file > *** text ***)     nosuchuser
  535.  
  536.        ______________________________________________________________________
  537.  
  538.        The user you wanted to contact is not present at this system.
  539.  
  540.        Please use the subject line as recipient - example "subject: freaker" would
  541.        send mail to freaker on this system.
  542.        ______________________________________________________________________
  543.  
  544.   4.4.  crontab files".
  545.  
  546.   If you don't know how crontab works :) better read the manual :) ...
  547.   You need to create a "checkmail" file - what will see if the link is
  548.   up, as well the cronfile itself ... - i am using a ppp link :) so -
  549.   this is an example how to look when the ppp link is up - and to poll
  550.   every 10 minutes using cron. Looks sloppy - but isn't !.
  551.  
  552.   4.4.1.  checkformail
  553.  
  554.   the .checkformail file will be called (needs to be executable as well)
  555.   - and will look if the ppp link is up. If it is up - then it will
  556.   fetch for mail.  Crontab will use this file when you are using the
  557.   below cronentry ...
  558.  
  559.        (*** < file > *** code ***)     .checkformail
  560.  
  561.   ______________________________________________________________________
  562.   #!/bin/sh
  563.   #
  564.  
  565.           cd /home/mailservice
  566.  
  567.           if [ -f /var/run/ppp0.pid ]; then
  568.           /usr/local/bin/fetchmail -s > /dev/null 2>&1
  569.   fi
  570.   ______________________________________________________________________
  571.  
  572.   4.4.2.  crontab
  573.  
  574.   This cronentry file needs to been loaded into crontab, and will call
  575.   the .checkformail - every 10 minutes. It won't write any mail or give
  576.   any info to the console - since i'm redirecting everything to null.
  577.  
  578.        (*** < file > *** text ***)     cronentry
  579.  
  580.        ______________________________________________________________________
  581.        0,10,20,30,40,50 * * * *  /home/mailservice/.checkformail 1> /dev/null 2> /dev/null
  582.        ______________________________________________________________________
  583.  
  584.   4.5.  At the admins site".
  585.  
  586.   Well, this should be done when using the "A method" ... at the admin's
  587.   site, so the email goes all from a complete domain, to one username.
  588.   It is pretty simple, and once you've done it - it works like hell.
  589.   this is NOT neccesary if your system administrator (the uplink) got
  590.   another method, and is NOT neccesary at YOUR side !!!!
  591.  
  592.   When using a newer version of sendmail, the "old sendmail" trick
  593.   probably won't work, so please refer to the "new sendmail" topics to
  594.   let your mailrouting work.
  595.  
  596.   4.5.1.  (old sendmail) add some lines to sendmail.cf
  597.  
  598.   add the following lines to your /etc/sendmail.cf file, so the domains
  599.   file will be read.  please be noted that the "ruleset 98" is added as
  600.   underhere, since - once you got errors :) it's a hell to find 'm out !
  601.   (and i can know it :) DuH).
  602.  
  603.        (*** < file > *** add ***)    /etc/sendmail.cf
  604.  
  605.   ______________________________________________________________________
  606.   # Database of handled domains
  607.  
  608.   Kmaildomains btree /etc/maildomains.db
  609.  
  610.   # Add these lines *IN* Ruleset 98 ! (under Ruleset 98).
  611.  
  612.   R$+ < @ $+  . >         $: $1 < @ $2 > .
  613.   R$+ < @ $+ > $*         $: $(maildomains $1@$2 $: $1 < @ $2 > $3 $)
  614.   R$+ < @ $+ > $*         $: $(maildomains $2 $: $1 < # $2 > $3 $)
  615.   R$+ < @ $* > .          $: $1 < @ $2 . >
  616.   ______________________________________________________________________
  617.  
  618.   4.5.2.  (new sendmail) Adding some lines to sendmail.cf
  619.  
  620.   With the newer sendmail releases (tested with sendmail v8.8.7, 8.8.8).
  621.   Ignore method A, and add the next lines ...
  622.  
  623.        (*** < file > *** add ***)    /etc/sendmail.cf
  624.  
  625.        ______________________________________________________________________
  626.        # Database of handled domains
  627.  
  628.        Fw/etc/sendmail.cw
  629.        Kvirtuser btree /etc/maildomains.db
  630.  
  631.        *OR*
  632.  
  633.        Fw/yourhomedir/sendmail.cw
  634.        Kvirtuser btree /yourhomedir/maildomains.db
  635.        ______________________________________________________________________
  636.  
  637.   4.5.3.  (new sendmail)editing the /etc/sendmail.cw (or /your¡
  638.   dir/sendmail.cw) file
  639.  
  640.   If you are using another "location" for the sendmail.cw file, then
  641.   please replace the "/etc/sendmail.cw" to
  642.   "/yourhomedirectory/sendmail.cw". The pro points of putting this
  643.   sendmail.cw file into your homedirectory is that you don't need root
  644.   to change the domains to receive on. tough - this can give security
  645.   risks if not used properly !
  646.  
  647.   This file can already exist, or needs to be created, if it already
  648.   exists be sure you don't overwrite the older data - or i need to refer
  649.   you to my fine disclaimer :)
  650.  
  651.   First create a /etc/sendmail.cw file, what will be used to "send" a
  652.   domain to a specific user ... here is an example ... (as you already
  653.   knew, the name "mailservice" can be anything you want - it can even be
  654.   your loginname (like mine is freaker).
  655.  
  656.        (*** < file > *** text ***) /etc/sendmail.cw
  657.  
  658.        ______________________________________________________________________
  659.        mydomain.dom            mailservice
  660.        ______________________________________________________________________
  661.  
  662.   4.5.4.  creating a /etc/maildomains file
  663.  
  664.   First create a /etc/maildomains file, what will be used to "send" a
  665.   domain to a specific user ... here is an example ... (as you already
  666.   knew, the name "mailservice" can be anything you want - it can even be
  667.   your loginname (like mine is freaker). (you could have this
  668.   /etc/maildomains in /yourhomedir/maildomains as mentioned before, just
  669.   change the paths :)
  670.  
  671.   With the OLDER sendmail versions:
  672.  
  673.        (*** < file > *** text ***)     /etc/maildomains
  674.  
  675.        ______________________________________________________________________
  676.        mydomain.dom            mailservice
  677.        ______________________________________________________________________
  678.  
  679.   With the NEWER sendmail versions:
  680.  
  681.        (*** < file > *** text ***)     /etc/maildomains
  682.  
  683.        ______________________________________________________________________
  684.        @mydomain.dom           mailservice
  685.        ______________________________________________________________________
  686.  
  687.   4.5.5.  let it work !
  688.  
  689.   With the old & new sendmail versionsyou need to generate the btree
  690.   (database) files, you'll need to do the following:
  691.  
  692.   cd /etc    (or /yourhomedir)
  693.   makemap btree maildomains < maildomains
  694.  
  695.   after that, kill the sendmail daemon, and restart it. it should now
  696.   WORK!  good luck :)
  697.  
  698.   5.  Automation
  699.  
  700.   Well, now, everything above works ... (if it doesn't work - don't even
  701.   think about automation before it WILL work ... - now - we need some
  702.   script so it isn't a pain in the ass for the "mailadministrator" or
  703.   the root user to add users to the procmailrc file ... The below
  704.   example will be for "more experienced users" - since some things NEED
  705.   to be changed as well ... - it is an example with the "B method -
  706.   Subject lines". It can be easily adapted to the "A method". Since the
  707.   "B method" will be more used (cheaper) than the "A" method - i decided
  708.   to use the "B method" ... Am i sounding repetitive or not ? .. well -
  709.   i meant to write it in this way :)) to bug you :)))..
  710.  
  711.   5.1.  The "skeleton".
  712.  
  713.   Since the footer needs to be as footer (everything below won't be
  714.   processed since we are bouncing there); there needs to be a header and
  715.   a footer file.
  716.  
  717.   5.1.1.  the ".procmailrc-header" file
  718.  
  719.   This file will now be the "header & user" file .. since here will
  720.   users been added and removed - it will be a important file ... - best
  721.   take a backup from it each time you add a user ... - there COULD be
  722.   something wrong sometime ..  A system can fail ...
  723.  
  724.        (*** < file > *** text ***) .procmailrc-header
  725.  
  726.   ______________________________________________________________________
  727.   :0 c
  728.           passtrough
  729.  
  730.   :0
  731.   * ^To:.*freaker@ibm.net
  732.   ! freaker
  733.  
  734.   :0
  735.   * ^Subject:.root
  736.   ! root
  737.  
  738.   :0
  739.   * ^Subject:.barbara
  740.   ! barbara
  741.  
  742.   :0
  743.   * ^Subject:.paul
  744.   ! paul@his.personal.emailaddress
  745.  
  746.   :0 c
  747.   * ^Subject:.john
  748.   ! john@his.personal.emailaddress
  749.  
  750.   :0
  751.   * ^Subject:.john
  752.   ! john
  753.  
  754.   :0
  755.   * ^From:.*newsletter@ibm.net
  756.   ! freaker
  757.  
  758.   :0
  759.   * ^FROM_DAEMON
  760.   throwaway
  761.   ______________________________________________________________________
  762.  
  763.   5.1.2.  the .procmailrc-footer file ..
  764.  
  765.   As mentioned above, this file needs to be as footer - since all data
  766.   BELOW it won't be used to deliver - this footer contains the "bounce"
  767.   code to bounce the users not found *ABOVE* this footer !. it is the
  768.   ABSOLUTE end of the file !
  769.  
  770.        (*** < file > *** text ***) .procmailrc-footer
  771.  
  772.   ______________________________________________________________________
  773.  
  774.   :0
  775.     |(/usr/bin/formail -r -k \
  776.        -A"X-loop: mailservice@mydomain.dom "| \
  777.          /usr/bin/gawk '{print }\
  778.          /^/ && !HEADER \
  779.            { system("/bin/cat nosuchuser"); \
  780.            print"--" ;\
  781.            HEADER=1 }' ) |\
  782.            /usr/bin/sendmail -t
  783.  
  784.   exit
  785.   ______________________________________________________________________
  786.  
  787.   5.2.  addmail script
  788.  
  789.   This script will add a user to the header file, attach the header &
  790.   footer to eachother - so it will be a complete .procmailrc file. the
  791.   "#" (comments) are not really needed - and are for your info :).
  792.  
  793.        (*** < file > *** code ***)     addmail   (* chmod 500 *)
  794.  
  795.   ______________________________________________________________________
  796.   #/bin/sh
  797.   #
  798.   # Copyright (c)1997 by Gunther Voet. rev 1.0.1
  799.   # please leave the Copyright in it when it is distributed with any
  800.   # system using this thingy ...
  801.  
  802.   echo ""
  803.   echo "Addmail v1.0.1 by Gunther Voet, Freaker / TuC'97-98 (21/04/97)"
  804.   echo ""
  805.  
  806.   if [ $1 ]; then
  807.  
  808.           if [ $2 ]; then
  809.  
  810.   # make a backup file !
  811.  
  812.           cp /home/mailserv/.procmailrc-header /home/mailserv/.procmailrc-backup
  813.  
  814.   # APPEND (>>) the information to the header file ...
  815.  
  816.           echo ":0" >> /home/mailserv/.procmailrc-header
  817.           echo "* ^Subject:.$1" >> /home/mailserv/.procmailrc-header
  818.           echo "! $2" >> /home/mailserv/.procmailrc-header
  819.           echo "" >> /home/mailserv/.procmailrc-header
  820.  
  821.   # copy the header file to .procmailrc - and append the footer file to it !
  822.  
  823.           cat /home/mailserv/.procmailrc-header > /home/mailserv/.procmailrc
  824.           cat /home/mailserv/.procmailrc-footer >> /home/mailserv/.procmailrc
  825.  
  826.   # make sure it is owned by "mailserv" and the read/write priveleges are ONLY
  827.   # for the user "mailserv" itself ...
  828.  
  829.           chown mailserv /home/mailserv/.procmailrc
  830.           chgrp users /home/mailserv/.procmailrc
  831.           chmod 600 /home/mailserv/.procmailrc
  832.   else
  833.           echo "No DESTINATION mail address has been given ..."
  834.   fi
  835.  
  836.   else
  837.           echo "usage:"
  838.           echo ""
  839.           echo "syntax:  addmail from_user to_user(domain)"
  840.           echo ""
  841.           echo "example: addmail freaker freaker@myemail.dom"
  842.           echo ""
  843.   fi
  844.   ______________________________________________________________________
  845.  
  846.   Now, this script will append the information of the user, as well the
  847.   email address to the header file, it will copy it to the .procmailrc
  848.   file, and will add the footer to it, so you got a complete .procmailrc
  849.   to process the mail.  If you want to delete a user- just edit the
  850.   .procmailrc-header file, and at the next user added it will be deleted
  851.   at the .procmailrc. To do a instant delete, just delete the user from
  852.   both the files .procmailrc & .procmailrc- header.
  853.  
  854.   I guess you are smart enough to write a script that'll automatically
  855.   add your users when using both methods - when doing a "adduser" at
  856.   your box.
  857.  
  858.   6.  Help! (sigh)
  859.  
  860.   Well, you need help - isn't :) ... hmm .. i could be sarcastic and
  861.   just say "you could better do it again, 'coz it looks a messy enuf" -
  862.   or .. i could help ... - I wrote down some common problems - IF you
  863.   got any problem NOT listed in this HOWTO (section) - then mail me -
  864.   and i'll put it in this howto even with your name/email addr in it :).
  865.   **BEFORE** mailing to me - please look if you didn't forgot anything -
  866.   and IF you want some help from me - send me the MOST DETAILED
  867.   information - included the scripts & things you needed.  i DON'T need
  868.   any binaries - since i won't run them.
  869.  
  870.   6.1.  The automation script just doesn't work:
  871.  
  872.   ╖  is it executable ?
  873.  
  874.   ╖  is your (default shell) located at /bin/sh ?
  875.  
  876.   6.2.  What do you mean by "anonymous mailserver"?
  877.  
  878.   ╖  Well, you could make accounts like "anon0001@yourdom.dom" - and
  879.      forward it to another email address ... nobody needs to read the
  880.      .procmailrc file, so YOU ONLY know the address !.
  881.  
  882.   6.3.  My cat died
  883.  
  884.   ╖  Well, next time don't print this HOWTO out on 200 gram papers,
  885.      since it are 10 pages it would be 2KG for the cat - it is JUST TOO
  886.      HEAVY !
  887.  
  888.   6.4.  My dog died
  889.  
  890.   ╖  hmm - can't do anything about that one - why askin' me ? ...  Just
  891.      bury it ....
  892.  
  893.   6.5.  Linux?
  894.  
  895.   ╖  A free-unix - posix compatible - made by Linus Torvalds ... Why are
  896.      you reading this if you even don't know what Linux is ?
  897.  
  898.   6.6.  Can you help me with finding a mail account?
  899.  
  900.   ╖  No! - this is a howto for YOUR side, i don't care about the side of
  901.      your isp, nor how to get your email address.
  902.  
  903.   6.7.  Why is the "maybe later i'll make some addition ..." removed ?
  904.  
  905.   ╖  Read point 5.5 very carefully :) and you'll see why .. it's 'coz i
  906.      needed to add it on general request :)
  907.  
  908.   6.8.  How do i get a "domain" ?
  909.  
  910.   ╖  Ask your local ISP/provider - he will help you with it. It could
  911.      take days/ even weeks when asking to the Internic - your provider
  912.      can help.
  913.  
  914.   6.9.  Why are you so f*cking lame using this?
  915.  
  916.   ╖  coz i don't want to spend money - and - 'coz i feel like being
  917.      f*cking lame USING it - i *AM* using it - so why bother?
  918.  
  919.   6.10.  Nosuchuserfile?
  920.  
  921.   ╖  You can put in it what you want - as long you put some "needed"
  922.      info so the original writer knows what happened with his "never
  923.      delivered" mail.
  924.  
  925.   6.11.  Can my users write/send mail too?
  926.  
  927.   ╖  This has nothing to do with the system i explained to you, read the
  928.      sendmail manual ... - this is to RECEIVE mail - to be "always
  929.      available at an email address".
  930.  
  931.   6.12.  Does every user need a shell account at my server?
  932.  
  933.   ╖  Nope .. - but - it will be really hard for users not having
  934.      internet access :) ... You could have a masq'd network - and use a
  935.      computer connected to it - so the users can get their mail that
  936.      way, or you can generate a link between a bulletin board and his
  937.      mail, you could even forward it to a fidonet gate :) ... reasons
  938.      enough not to give a shell!.
  939.  
  940.   6.13.  skeletion?
  941.  
  942.   ╖  i know it is a typo - but - i like this word better.
  943.  
  944.   6.14.  Addmail?
  945.  
  946.   ╖  No questions - for automation - you better be sure about what you
  947.      are going to do ... since - it COULD be a trojan ya know :))) (it
  948.      isn't but what means you need to know what scripting is before
  949.      asking questions) It IS easy enough to interprete - that's even why
  950.      i put the comments with it. *IF* you are going to distribute this
  951.      script - leave my Copyright in it please ! thanks :).
  952.  
  953.   6.15.  Why are you so cruel?
  954.  
  955.   ╖  I am not cruel :) i am nice :) i am the nicest guy of the world, of
  956.      the universe ! NOW SCRAM! (i just want to be complete in my HOWTO,
  957.      and not TOO much "drifting away" from my original point in the doc
  958.      - so :) that's all).
  959.  
  960.   6.16.  Didn't you get a complaint of excessive language ?
  961.  
  962.   ╖  Not yet, but, could be i'm filtering everything containing
  963.      'excessive' and language :) i don't know :))
  964.  
  965.   6.17.  Why is this howto different than most others?
  966.  
  967.   ╖  coz sometimes reading plain howto's CAN be boring ... i wanted to
  968.      add something next to it ...
  969.  
  970.   6.18.  locally my domain works, but remote it seems not to receive
  971.  
  972.   ╖  Check out your "sendmail.cw" file, since the domains NEED to be
  973.      added in it !
  974.  
  975.   6.19.  My dog died
  976.  
  977.   ╖  the rulesets don't work, i can't receive any mail, or sendmail dies
  978.      Refer to the new section "new sendmail" - and disregard the old
  979.      sendmail tricks. The newer sendmail should be easier to use with
  980.      virtual domains.
  981.  
  982.   7.  The End
  983.  
  984.   This sounds like the end ... If you find any unwanted bugs (or
  985.   features :)), then leave some feedback ... any comments & suggestions
  986.   -> mail them :).  if you are still bored after reading this, please go
  987.   to: http://tuc.ml.org/  hehehe.
  988.  
  989.   My thanks go out to:
  990.  
  991.   Hannes van de Vel: for supporting me (hum) Tetsu Isaji: the japanese
  992.   offline-mailing & notifying me about errors :) Greg Hankins: for
  993.   notifying me about some errors in the sgml version.  Linus torvalds:
  994.   of'course ... without his help this howto wouldn't be here!
  995.  
  996.